<!--Pdf-->
<script type="text/javascript">
    function printPage(id)
    {

        var html="<fieldset>";
        html+= document.getElementById(id).innerHTML;
        html+="</fieldset>";

        var printWin = window.open('','','left=0,top=0,width=1,height=1,toolbar=0,scrollbars=0,status =0');
        printWin.document.write(html);
        printWin.document.close();
        printWin.focus();
        printWin.print();
        printWin.close();

        var html="<html>";
        html+="<head>";
        html+="<style type='text/css'>.mytable{border:1px solid #ccc;}.mytable tr{background-color:#008000;color:#FFF;}</style>";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/report.css' media='print' />";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/style_master.css' media='print' />";
        html+="<link rel='Stylesheet' type='text/css' href='<?php echo base_url(); ?>/css/jdate_picker/jquery.ui.all.css' media='print' />";
        html+="</head>";
        html+= document.getElementById(id).innerHTML;
        html+="</html>";
    }
</script>

<!--<script type="text/javascript">jQuery.noConflict()</script>-->
<link href="<?php echo base_url(); ?>css/report.css" rel="stylesheet" type="text/css" />  
<script type="text/javascript" language="javascript" src="<?php echo base_url() ?>media/js/jquery.js"></script>
<script type="text/javascript" language="javascript" src="<?php echo base_url() ?>media/js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8">
    $(document).ready(function() {
        $('.example').dataTable();
    } );

</script>

<style type="text/css" title="currentStyle">
    @import "<?php echo base_url() ?>media/css/demo_page.css";
    @import "<?php echo base_url() ?>media/css/demo_table.css";
</style>
<div class="form-wrapper">
    <br/>
    <fieldset id="year" style="margin: 0 auto;width:91.5%;height: auto;border: 1px #ccc solid; padding:20px;-moz-border-radius:10px;">
        <?php
        echo '<div style="float: right; border: 0px #ccc solid; margin-right: 15px;">';
        echo anchor('report/manager', img('images/user_images/cancel.png'));
        echo '</div>';
        ?>   
        <?php
        echo '<div id="subheader">';
        echo img(array('src' => 'images/NRY001_Logo-FINAL-master_01-horiz.jpg', 'alt' => 'logo', 'align' => 'left', 'width' => '150')) . '&nbsp;&nbsp;&nbsp;&nbsp;';
        echo '<h1 style="text-align:center;color:#008000;">Yearly Report</h>';
        echo'</div>';
       echo '<br/><div style="float:right;color:#008000;width:25%; text-align:center;">View Yearly Report For  Year&nbsp;:' . '<b style="color:red;">  &nbsp;' . date("Y") . '</b><br/>';
      ?>
        To print this report, Click here <a href="#"><img src="<?php echo base_url(); ?>/images/user_images/print.png" align="center" onclick="printPage('year')" id="image"  alt="Print yearly report" title="Print yearly report"/></a>
         </div> 
        <div style="margin: 0 auto;width: 100%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600;">Public Class Yearly</div><br/>
        <div class="Tcontrol" style="margin: 0 auto; float: right;width:70px;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600;"></div><br/><br/>


        <!-- form of view report public monthly report-->
        <?php
        $data = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ) ) and car_type_name="public" ');
        $this->db->where('YEAR( sal_date ) = YEAR( CURDATE( ) )');
        $year = $this->db->get('tbl_sale');
        if ($year->num_rows() > 0) {
            if ($data->num_rows() > 0) {
                ?>
                <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
                    <div class="full_width big"></div>
                    <div id="demo">
                        <table cellpadding="0" cellspacing="0" border="0" id="mytable"  class="example"  width="100%" style="margin:auto;">
                            <thead>
                                <tr style="color:#FFF;height:28px;border:1px;text-align: center;font-weight: lighter;">
                                    <th style="border:1px solid #ccc;">N&ordm</th>
                                    <th style="border:1px solid #ccc;">Date</th>
                                    <th style="border:1px solid #ccc;">Seller</th>
                                    <th style="border:1px solid #ccc;">Items</th>
                                    <th style="border:1px solid #ccc;">Quantity</th>
                                    <th style="border:1px solid #ccc;">Unit Price</th>
                                    <th style="border:1px solid #ccc;">Payment</th>
                                    <th style="border:1px solid #ccc;">Credit</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                /* ===========Query Select view Year report Public card=============== */
                                $data = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ) ) and car_type_name="public" ');

                                $j = 1;
                                foreach ($data->result() as $value) {
                                    echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
<td>' . $j . '</td>
                  <td style="border:1px solid #ccc;">' . $value->sal_date . '</td>
                  <td style="border:1px solid #ccc;">' . $value->use_username . '</td>
                  <td style="border:1px solid #ccc;">' . $value->car_name . '</td>
                  <td style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                  <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                  <td style="border:1px solid #ccc;">$' . $value->sal_payment . '</td>
                  <td style="border:1px solid #ccc;">$' . (($value->sal_price * $value->sal_quantity) - ($value->sal_payment)) . '</td>
                  </tr>';
                                    $j++;
                                }
                                echo '</tbody><table></div><br/> ';
                            }
                            //===============query select total for public card that has sold for this year====================

                            $data_card = $this->db->query('SELECT sum(sal_quantity * sal_price) AS total, SUM(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ))  and car_type_name="public" ');

//        echo '<br /><div style="width:270px; float:right;border:1px solid #ccc;padding:10px; text-align:left;"><b style="color:red;font-weight:Bold;margin-right:60px;">Total : </b>';
//        foreach ($data_card->result() as $value) {
//            echo '<b style="color:red;text-align:center;font-weight:Bold;margin-right:80px;">$' . $value->total . '</b>';
//            echo '<b style="color:red;font-weight:Bold;text-align:center;font-weight:Bold;">$' . $value->credit . '</b>';
//        }
//        echo '</div>';
//        echo '<br/><br/><br/><br/>';

                            /* ===========Query Select view Year report Public card for calculate price =============== */
                            $data_card = $this->db->query('SELECT sum(sal_quantity * sal_price) AS total, SUM(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ))  and car_type_name="public" ');

                            if ($data_card->num_rows() > 0) {
                                echo '<br /><table class="mytable" cellpadding="0" cellspacing="0" style="float:right;text-align:center;>';
                                echo '<tr style=" color: #FFF; background-color:#E8F6FE;>';
                                echo '<th style="background-color:#5C9416; color:#FFF;"height="20px"  width="100px">Total</th>';
                                echo '<th style="background-color:#5C9416;color:#FFF;"height="20px" width="100px"><center>Credit</center></th>';
                                echo '</tr>';
                                echo '<tr>';
                                foreach ($data_card->result() as $value) {
                                    echo '<td style="color:red;"><center>$' . $value->total . '</center></td>';
                                    echo '<td style="color:red;font-weight:Bold;text-align:center; width:20px;">$' . $value->credit . '</td>';
                                }
                                echo ' </tr>';
                            }
                            echo '</table>';
                            ?>

                        <div class="spacer"></div>

                        <!--===========End view Year report Public card===============-->
                </div><br /><br />

                <!-- ===========form of view report private Yearly report=======================================-->
                <div style="margin: 0 auto;width: 100%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600;">Private Class and WorkShop/Retreat</div><br/>

                <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
                    <div class="full_width big"></div>
                    <div id="demo">
                        <table cellpadding="0" cellspacing="0" border="0" id="mytable" class="example" width="100%">
                            <thead>
                                <tr style="height:28px;background-color:#5C9416;color:#FFF;border:1px;text-align: center;font-weight: lighter;">
                                    <th style="border:1px solid #ccc;">N&ordm</th>
                                    <th style="border:1px solid #ccc;">Date</th>
                                    <th style="border:1px solid #ccc;">Seller</th>
                                    <th style="border:1px solid #ccc;">Items</th>
                                    <th style="border:1px solid #ccc;">Quantity</th>
                                    <th style="border:1px solid #ccc;">Unit Price</th>
                                    <th style="border:1px solid #ccc;">Payment</th>
                                    <th style="border:1px solid #ccc;">Credit</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php
                                $data_private = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ))  and car_type_name="private" ');

                                $j = 1;
                                foreach ($data_private->result() as $value) {
                                    echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
                            <td style="border:1px solid #ccc;">' . $j . '</td>
                            <td>' . $value->sal_date . '</td>
                            <td style="border:1px solid #ccc;">' . $value->use_username . '</td>
                            <td style="border:1px solid #ccc;">' . $value->car_name . '</td>
                            <td style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                            <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                            <td style="border:1px solid #ccc;">$' . ($value->sal_quantity * $value->sal_price) . '</td>
                            <td style="border:1px solid #ccc;">$' . (($value->sal_price * $value->sal_quantity) - ($value->sal_payment)) . '</td>
                            </tr>';
                                    $j++;
                                }
                                ?>
                            </tbody>
                        </table><br /><br /><br />
                        <!--===========Query select Total price private card for view report===============-->
                        <?php
                        $data_cards = $this->db->query('SELECT sum(sal_quantity * sal_price) AS total,sum(sal_quantity * sal_price) AS totals, SUM(sal_quantity * sal_price - sal_payment) AS credit
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="private" ');
                        if ($data_cards->num_rows() > 0) {
                            echo '<table cellpadding="0" cellspacing="0" class="mytable" style="float:right;text-align:center; ">';
                            echo '<tr style=" color: #FFF; background-color:#E8F6FE;">';
                            echo ' <th  style="background-color:#5C9416;"height="20px" width="100px" ><center>Total</center></th>';
                            echo '<th  style="background-color:#5C9416;"height="20px" width="100px"><center>Credit</center></th>';
                            echo '</tr>';
                            echo '</tr>';
                            foreach ($data_cards->result() as $value) {
                                echo '<td style="color:red;"><center>$' . $value->total . '</center></td>';
                                echo '<td style="color:red;font-weight:Bold;text-align:center;">$' . $value->credit . '</td>';
                            }
                            echo ' </tr>';
                        }
                        echo '</table>';
                        ?>
                        <br /><br /><br />
                        <!--===================End view report private monthly report//==========-->

                        <!--//========== form of view report product Management monthly report//==========-->
                        <?php
                        $data_product = $this->db->query('SELECT  sal_date,sal_quantity,sal_price, pro_name, sal_date
,use_username FROM tbl_sale
INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ))  ');
                        if ($data_product->num_rows() > 0) {
                            ?>
                            <div style="margin: 0 auto;width: 100%;height: auto;border: 0px #ccc solid;text-align: center;font-size: 20px;color:#006600; clear: both;">Product Yearly </div>
                            <div class="task1" style="float: left; width: 100%;height: auto;border: 0px #ccc solid;padding: 5px;">
                                <div class="full_width big"></div>
                                <div id="demo">
                                    <table cellpadding="0" cellspacing="0" border="0" id="mytable" class="example" width="100%">
                                        <thead>
                                            <tr style=" height:28px;background-color:#5C9416;color:#FFF;border:1px;text-align: center;font-weight: lighter;">
                                                <th style="border:1px solid #ccc;">N&ordm</th>
                                                <th style="border:1px solid #ccc;">Date</th>
                                                <th style="border:1px solid #ccc;">Seller</th>
                                                <th style="border:1px solid #ccc;">Items</th>
                                                <th style="border:1px solid #ccc;">Quantity</th>
                                                <th style="border:1px solid #ccc;">Unit Price</th>
                                                <th style="border:1px solid #ccc;">Payment</th>
                                            </tr>
                                        </thead>
                                        <tbody>
                                            <?php
                                            $data_private = $this->db->query('SELECT *
FROM tbl_sale
INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
WHERE month( sal_date ) = month( curdate( ) ) and car_type_name="private" ');

                                            $j = 1;
                                            foreach ($data_product->result() as $value) {
                                                echo '<tr style="text-align:center;color:#000;font-weight: lighter;">
                              <td style="border:1px solid #ccc;">' . $j . '</td>
                              <td style="border:1px solid #ccc;">' . $value->sal_date . '</td>
                              <td style="border:1px solid #ccc;"> ' . $value->use_username . '</td>
                              <td style="border:1px solid #ccc;">' . $value->pro_name . '</td>
                              <td style="border:1px solid #ccc;">' . $value->sal_quantity . '</td>
                              <td style="border:1px solid #ccc;">$' . $value->sal_price . '</td>
                              <td style="border:1px solid #ccc;"> $' . ($value->sal_quantity * $value->sal_price) . '</td>
                              </tr>';
                                                $j++;
                                            }
                                            ?>
                                        </tbody>
                                    </table><br /><br />

                                    <?php
                                }

                                $data_product_total = $this->db->query('SELECT  sum(sal_quantity * sal_price ) AS total
                                FROM tbl_sale
                                INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
                                JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
                                WHERE YEAR( sal_date ) = YEAR( CURDATE( ))');
                                $data_total_amount = $this->db->query('SELECT  sum(sal_quantity * sal_price ) as total_amount , sum(sal_quantity * sal_price - sal_payment) AS credit_amount
                                FROM tbl_sale
                                INNER JOIN tbl_card ON tbl_card.car_id = tbl_sale.car_id
                                JOIN tbl_car_type ON tbl_car_type.car_type_id = tbl_card.car_type_id
                                WHERE YEAR( sal_date ) =YEAR( CURDATE( ))');
                                foreach ($data_total_amount->result() as $rows) {
                                    $tal = $rows->total_amount;
                                    $credit_amount = $rows->credit_amount;
                                }
                                $data_product_amount = $this->db->query('SELECT  sum(sal_quantity * sal_price ) AS total_pro
FROM tbl_sale
INNER JOIN tbl_product ON tbl_product.pro_id = tbl_sale.pro_id
JOIN tbl_pro_type ON tbl_pro_type.pro_type_id = tbl_product.pro_type_id
WHERE YEAR( sal_date ) = YEAR( CURDATE( ))   ');
                                foreach ($data_product_amount->result() as $row) {
                                    $total_pro = $row->total_pro;
                                }
                                $total_amount = $total_pro + $tal;
                                $totalall = $total_amount - $credit_amount;
                                echo '<table cellpadding="0" cellspacing="0" class="mytable" style="float:right;text-align:center; ">';
                                echo '<tr style="color: #FFF; background-color:#E8F6FE;">';
                                echo ' <th  style="background-color:#5C9416;"height="20px" width="100px" ><center>Total</center></th>';
                                echo '</tr>';
                                foreach ($data_product_total->result() as $value) {
                                    echo '<td style="color:red;"><center>$' . $value->total . '</center></td>';
                                }
                                echo '</tr></table>';

                                echo '<br/>';
                                echo '<br/><br/><br/><br/><table class="mytable" width="100%" cellspacing="0" cellpadding="0" border="0"><tr style="background-color:#E8F6FE;">';
                                echo ' <td colspan="6" style="border:1px solid #ccc;text-align:right;font-size:16px;color:#008000;font-weight:Bold;width:90%;">Total Amoun :<br/><br/>Total Credit :<br/><br/>Yearly Income :<br/><td>';
                                foreach ($data_product_total->result() as $value) {
                                    echo '<p style="color:red; text-align:center;" align="center">$' . $total_amount . '<br/><br/> $' . $credit_amount . '<br/><br/>$' . $totalall . '</p>';
                                }
                                echo ' </tr>';

                                echo '</table>';
                            }
                            echo '</fieldset>';

                            echo '</div>';
                            echo '</div>';
                            ?>
                        </div>
                        <div class="spacer"></div>
                        <h1>&nbsp;</h1>

                    </div>






